package com.neuedu.page_objects;

import com.fasterxml.jackson.databind.ser.Serializers;
import com.neuedu.bases.BasePage;
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;

public class ManagerPage extends BasePage {
    public ManagerPage(ChromeDriver driver){
        super(driver);
    }

    public void Login()
    {
        waitSleep(1);
        findElement(By.cssSelector("[placeholder=username]")).sendKeys("admin");
        findElement(By.cssSelector("[placeholder=password]")).sendKeys("admin");
        waitSleep(1);
        findElement(By.className("login-btn")).click();
    }

    public void assignPerson(){
        findElement(By.className("el-input__inner")).click();
        waitSleep(1);
        findElements(By.className("el-select-dropdown__item")).get(2).click();
    }

    public String getButtonId(String id){
        return findElement(By.id(id)).getText();
    }

    public void clickButton(String id){
        findElement(By.id(id)).click();
    }

    public String getMessage(){
        return findElement(By.cssSelector("p[class='el-message__content']")).getText();
    }

    public String getIssues(int index){
        return findElements(By.className("cell")).get(index).getText();
    }

    public void inputReason(String info){
        findElement(By.className("el-textarea__inner")).sendKeys(info);
    }

    public void goOtherPage(int index){
        findElements(By.className("el-menu-item")).get(index).click();
    }

    public void inputInfoName(String name){
        findElements(By.className("el-input__inner")).get(0).sendKeys(name);
    }

    public void inputInfoGender(int index){
        findElements(By.className("el-input__inner")).get(1).click();
        waitSleep(1);
        findElements(By.className("el-select-dropdown__item")).get(index).click();
    }

    public void inputInfoState(int index){
        findElements(By.className("el-input__inner")).get(2).click();
        waitSleep(1);
        findElements(By.className("el-select-dropdown__item")).get(index+3).click();
    }
}
